#include"Slist.h"

void SLTPrint(SLTNode* phead)
{
    SLTNode* pcur = phead;
    while(pcur)
    {
        printf("%d",pcur->data);
        pcur = pcur->next;
    }
    printf("NULL\n");
}

SLTNode* SLTBuyNode(SLTDataType x)
{
    SLTNode* newnode = (SLTNode*)malloc(sizeof(SLTNode));
    if(newnode == 0)
    {
        printf("malloc fail");
        exit(1);
    }
    newnode->data = x;
    newnode->next = NULL;

    return newnode;
}


void SLTPushBack(SLTNode** pphead,SLTDataType x)
{
   assert(pphead);
   SLTNode* newnode = SLTBuyNode(x);
   if(* pphead == NULL)
   {
    * pphead = newnode;
   }
   else{
    SLTNode * ptail *pphead;
    while(ptail->next)
    {
        ptail = ptail->next;
    }
    ptail->next = newnode;
   }
}

void SLTPushFront(SLTNode* pphead,SLTDataType x)
{
    assert(pphead);
    SLTNode* newnode = SLTBuyNode(x);
    newnode->next = *pphead;
    *pphead = newnode;
}

void SLTPopBack(SLTNode** pphead)
{
    
}

void SLTPopFront(SLTNode** pphead);